<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商品列表</title>
<link href="<%=basePath%>skin/css/bootstrap/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath%>skin/css/public.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath%>skin/css/list.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath%>skin/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/select-widget-min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/public.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/common.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/bootstrap/bootstrap-paginator.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	navi();
	
	var productCategoryId = "${productCategory.id }";
	var keyword = "${paramBean.keyword }";
	var psort = "${paramBean.psort }";
	if(psort != null && psort != "null" && psort != "") {
		$("#psort_"+psort).addClass("curr");
	} else {
		$("#psort_0").addClass("curr");
	}
	
	var currentPage = "${ pagination.currentPage}";
	var totalPages = "${ pagination.pageCount}";
	var numberOfPages = "${ pagination.pageSize}";
	var keyword = encodeURI("${paramBean.keyword }");
    var options = {
		currentPage: currentPage,
		totalPages: totalPages,
		numberOfPages: numberOfPages,
		pageUrl:function(type, page, current){
			return basePath+"shop/product/list.shtml?productCategoryId="+productCategoryId+"&keyword="+keyword+"&psort="+psort+"&p="+page;
		}
	}
	
    try {
    	$("#paginator").bootstrapPaginator(options);
    } catch (e) {}
}); 
</script>
</head>
<body>
	<div class="list">
    	<div class="container">
        	<div class="header-wrap">
            	<c:import url="/layouts/top.jsp" />
                <c:import url="/layouts/head.jsp" />
                <div class="nav-warp">
					<div class="nav-main-warp wp">
						<div class="head-v3">
							<div class="navigation-up">
								<div class="navigation-inner">
									<div class="navigation-v3">
										<ul>
											<li class="fLeft navi_product first" _t_nav="product">
												<h2>
													<a href="<%=basePath%>shop/product/list.shtml">全部产品
														<img src="<%=basePath%>skin/images/all-product-arrow.png" />
													</a>
												</h2>
											</li>
											<li class="nav-up-selected-inpage fLeft" _t_nav="home">
												<h2>
													<a href="<%=basePath%>">美嘉商城</a>
												</h2>
											</li>
											<li class="fLeft self_community" _t_nav="community">
												<h2>
													<a href="javascript:void(0)">美嘉社区</a>
												</h2>
											</li>
											<li class="fLeft technology" _t_nav="technology">
												<h2>
													<a href="#">饲养技术</a>
												</h2>
											</li>
											<li class="fLeft server" _t_nav="server">
												<h2>
													<a href="">美嘉服务</a>
												</h2>
											</li>
											<li class="fLeft know" _t_nav="know">
												<h2>
													<a href="aboutMJ.html">了解美嘉</a>
												</h2>
											</li>
											<li class="fLeft navi_cart" _t_nav="cart">
												<h2>
													<a href="<%=basePath%>cart/list.shtml">
														<img src="<%=basePath%>skin/images/cart-icon.png" />购物车（<span id="cartnum">0</span>）
													</a>
												</h2>
											</li>
										</ul>
									</div>
								</div>
							</div>
							<div class="navigation-down">
								<div id="product" class="nav-down-menu menu-1"
									style="display: none;" _t_nav="product">
									<div class="navigation-down-inner">
										<c:forEach items="${productCategoryTree }" var="productCategory">
											<c:if test="${productCategory.grade == 0 }">
												<div class="navi-down-area">
													<a href="<%=basePath%>shop/product/list.shtml?productCategoryId=${productCategory.id }" class="product-cate">
														<img src="<%=basePath%>download.shtml?filepath=${productCategory.source}" />
													</a>
													<ul>
														<li><a href="<%=basePath%>shop/product/list.shtml?productCategoryId=${productCategory.id }">${productCategory.name}</a></li>
														<div class="clear"></div>
													</ul>
												</div>
											</c:if>
										</c:forEach>
									</div>
								</div>
								
								<div id="community" class="nav-down-menu menu-3" style="display: none;" _t_nav="community">
                                    <div class="navigation-down-inner">
                                    	<div class="navi-down-area-second">
                                        	<a href="<%=basePath%>forumTopic/list.shtml" class="product-cate"><img src="<%=basePath%>skin/images/mjbbs.png" /></a>
                                        </div>
                                        <div class="navi-down-area-second">
                                        	<a href="<%=basePath%>collegeTopic/list.shtml" class="product-cate"><img src="<%=basePath%>skin/images/mjschool.png" /></a>
                                        </div>
                                    </div>
                                </div>
							</div>
						</div>
					</div>
				</div>
            </div>
        	<div class="content clearfix">
				<div class="m-list">
                    <div class="ml-wrap">
                        <div class="filter">
                        	<div class="f-line clearfix">
                                <div class="f-feature">
                                    <ul>
                                        <li>商品分类：</li>
                                        <li id="leibie_all"><a href="<%=basePath%>shop/product/list.shtml?keyword=${paramBean.keyword }">全部</a></li>
										<c:set var="leibie" value="0" />
										<c:forEach items="${productCategoryTree }" var="productCategoryleibie">
											<li id="leibie_${productCategoryleibie.id }">
												<a href="<%=basePath%>shop/product/list.shtml?productCategoryId=${productCategoryleibie.id }&keyword=${paramBean.keyword }">${productCategoryleibie.name }</a>
											</li>
											<c:set var="leibie" value="${leibie+1 }" />
										</c:forEach>
                                    </ul>
                                </div>
                            </div>
                            <div class="f-line top">
                                <div class="f-sort">
                                    <a id="psort_0" href="<%=basePath%>shop/product/list.shtml?productCategoryId=${productCategory.id }&keyword=${paramBean.keyword }&psort=0">最新<i></i></a>
                                    <a id="psort_1" href="<%=basePath%>shop/product/list.shtml?productCategoryId=${productCategory.id }&keyword=${paramBean.keyword }&psort=1">价格从低到高<i></i></a>
                                    <a id="psort_2" href="<%=basePath%>shop/product/list.shtml?productCategoryId=${productCategory.id }&keyword=${paramBean.keyword }&psort=2">价格从高到低<i></i></a>
                                    <a id="psort_3" href="<%=basePath%>shop/product/list.shtml?productCategoryId=${productCategory.id }&keyword=${paramBean.keyword }&psort=3">关注度<i></i></a>
                                </div>
                            </div>
                            <div class="goods-list-v1 J-goods-list">
                                <ul class="gl-warp clearfix">
                                	<c:forEach items="${ pagination.recordList}" var="product">
	                                    <li class="gl-item">
	                                        <div class="gl-i-wrap">
	                                            <div class="p-img">
	                                                <a href="<%=basePath%>shop/product/detail.shtml?productId=${product.id}" target="_blank">
	                                                	<img width="220" height="220" title="${product.name}" src="<%=basePath%>download.shtml?filepath=${product.thumbnail} "/>
	                                                </a>
	                                                <div class="picon pi1"><b></b></div>
	                                            </div>
	                                            <div class="p-price" >
	                                                <strong><fmt:formatNumber value="${product.price}" pattern="0.00"/>元</strong>
	                                            </div>
	                                            <div class="p-name">
	                                                <a href="<%=basePath%>shop/product/detail.shtml?productId=${product.id}" target="_blank">
	                                                    <em>${product.name}</em>
	                                                </a>
	                                            </div>
	                                            <div class="p-operate">
	                                                <a href="javascript:addCar(${product.id });">加入购物车</a>
	                                                <a href="javascript:addFavorite(${product.id });"><i></i>添加关注</a>
	                                            </div>
	                                        </div>
	                                    </li>
                                    </c:forEach>
                                </ul>
                            </div>
                            <div class="page clearfix">
                                <div class="p-wrap" id="paginator">
                            	</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
			<c:import url="/layouts/foot.jsp" />
    	</div>        
    </div>
</body>
</html>
